
    $("#jqGrid").jqGrid({
        url: select_url + 'log_instance',
        mtype: 'POST',
        datatype: "json",
        colModel: [
            {
                label: '序号',
                name: 'id',
                width: 50,
                key: true,
                editable: false,
                editrules : { required: true},
                hidden: true
            },
            {
                label: '客户名称',
                name: 'clientname',
                width: 100,
                editable: false
            },
            {
                label : '仪表编号',
                name: 'deviceid',
                width: 100,
                editable: false
            },
            {
                label : '地理位置',
                name: 'pos',
                width: 150,
                editable: false
            },
            {
                label: '更新时间',
                name: 'time',
                width: 200,
                editable: false,
                // edittype: 'datetime-local',
                // editrules:{edithidden:true,required:true,date:true},
                // fixed: true, formatter: 'date',
                // formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'}
            },
            {
                label: '信号',
                name: 'signal',
                width: 80,
                editable: false,
                formatter: function(cellvalue, options, rowObject){
                    var temp = "<img src='assets/img/signal/";
                    if(cellvalue > -85){
                        temp = temp +"signal3.png";
                    } else if(signal < -85 && signal >= -95){
                        temp = temp +"signal3.png";
                    } else if(signal < -95 && signal >= -105){
                        temp = temp +"signal2.png";
                    }else if(signal < -105 && signal >= -115){
                        temp = temp +"signal1.png";
                    }else if(signal < -115 && signal >= -140){
                        temp = temp +"signal0.png";
                    }
                    temp = temp + "' alt='信号' style='width:30px; height:20px;' />";
                    return temp;
                }
            },
            {
                label: '压力',
                name: 'press',
                width: 80,
                classes: 'red',//红色字
                editable: false
            },
            {
                label : '温度',
                name: 'temp',
                width: 80,
                classes: 'red',//红色字
                editable: false
            },
            {
                label : '电池电压',
                name: 'vol',
                width: 80,
                classes: 'red',//红色字
                editable: false
            },
            {
                label: '电量',
                name: 'ele_charge',
                width: 80,
                editable: false,
                formatter: function(cellvalue, options, rowObject){
                    var temp = "<div alt='电量' style='width:34px; height:20px; background:url(assets/img/battery/dump-energy.png) no-repeat ";
                    var electricity = parseInt(cellvalue);
                    if(electricity == 0) elec = "-2px -10px"; 
                    else if(electricity > 0 && electricity <= 5) elec = "-40px -10px";
                    else if(electricity > 5 && electricity <= 15) elec = "-78px -10px";
                    else if(electricity > 15 && electricity <= 20) elec = "-116px -10px";
                    else if(electricity > 20 && electricity <= 25) elec = "-2px -48px";
                    else if(electricity > 25 && electricity <= 35) elec = "-40px -48px";
                    else if(electricity > 35 && electricity <= 40) elec = "-78px -48px";
                    else if(electricity > 40 && electricity <= 45) elec = "-116px -48px";
                    else if(electricity > 45 && electricity <= 50) elec = "-2px -86px";
                    else if(electricity > 50 && electricity <= 55) elec = "-40px -86px";
                    else if(electricity > 55 && electricity <= 60) elec = "-78px -86px";
                    else if(electricity > 60 && electricity <= 65) elec = "-116px -86px";
                    else if(electricity > 65 && electricity <= 70) elec = "-2px -124px";
                    else if(electricity > 70 && electricity <= 75) elec = "-40px -124px";
                    else if(electricity > 75 && electricity <= 80) elec = "-78px -124px";
                    else if(electricity > 80 && electricity <= 85) elec = "-116px -124px";
                    else if(electricity > 85 && electricity <= 90) elec = "-2px -162px";
                    else if(electricity > 90 && electricity <= 95) elec = "-40px -162px";
                    else if(electricity > 95 && electricity < 100) elec = "-78px -162px";
                    else if(electricity == 100) elec = "-116px -162px";
                    temp = temp + elec + ";'></div>";
                    return temp;
                }
            },
            {
                label: '采集周期',
                name: 'col_cycle',
                width: 80,
                editable: false
            },
            {
                label: '状态',
                name: 'status',
                width: 80,
                editable: false,
                edittype:'select',formatter : 'select',
                editoptions : {
                    value:"1 : <span class='label label-success'>在线</span>; 0 : <span class='label label-inverse'>离线</span>"
                }
            },
            {
                label: '查看曲线',
                width: 80,
                formatter: function(cellvalue, options, rowObject){
                    var html="<a href=\'history-data-chart.html?deviceId="+rowObject.deviceid+"\'><img src=\'assets/img/signal/3DChart.png\' alt=\'查看曲线\' title=\'查看曲线\'></a>";
                    return html;
                }
            },
            {
                label: '查看数据',
                width: 80,
                formatter: function(cellvalue, options, rowObject){
                    var html="<a href=\'history-data-detail.html?deviceId="+rowObject.deviceid+"\'><img src=\'assets/img/signal/HistoricalReport.png\' alt=\'查看历史数据\' title=\'查看历史数据\'></a>";
                    return html;
                }
            }
        ],

        jsonReader: {
            root: 'rows',
            repeatitems : false,
            id: "0"
        },
        rowNum:10,
        rowList:[10,20,30],
        sortname: 'id',
        sortorder : 'desc',//倒序 最新的数据在前
        viewrecords: true,
        rownumbers: true, //行序号
        rownumWidth: 25,
        width: 1345,
        height: 350,
        pager: "#jqGridPager",
        // styleUI: 'jQueryUI',
        shrinkToFit: false
        
    });


    var template = "<div style='margin-left:15px;'><div> 客户名称 <sup>*</sup>:</div><div>{clientname} </div>";
    template += "<div> 仪表编号: </div><div>{deviceid} </div>";
    template += "<div> 地理位置: </div><div>{pos} </div>";
    template += "<div> 更新时间:</div><div> {time} </div>";
    template += "<div> 信号: </div><div>{signal} </div>";
    template += "<div> 压力: </div><div>{press} </div>";
    template += "<div> 温度: </div><div>{temp} </div>";
    template += "<div> 电量:</div><div> {ele_charge} </div>";
    template += "<div> 电池电压:</div><div> {vol} </div>";
    template += "<div> 采集周期:</div><div> {col_cycle} </div>";
    template += "<div> 状态:</div><div> {status} </div>";
    template += "<hr style='width:100%;'/>";
    template += "<div> {sData} {cData}  </div></div>";

    

    $('#jqGrid').navGrid('#jqGridPager',
        // the buttons to appear on the toolbar of the grid
        { edit: false, add: false, del: false, search: false, refresh: true, view: false, position: "left", cloneToTop: false }
    );